<template>
  <div class="app-container">
    <el-form :inline="true" :model="form" class="demo-form-inline">
      <el-form-item label="解约协议编号">
        <el-input v-model="form.sfTerminationNo" placeholder="解约协议编号"></el-input>
      </el-form-item>
      <el-form-item label="小区名称">
        <el-input v-model="form.premiseName" placeholder="小区名称"></el-input>
      </el-form-item>
      <el-form-item label="录入人">
        <el-input v-model="form.username" placeholder="录入人"></el-input>
      </el-form-item>
      <el-form-item label="协议录入日期">
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="form.t1" style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">至</el-col>
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="form.t2" style="width: 100%;"></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="success" @click="onSubmit">查询</el-button>
        <el-button type="warning" plain @click="empty">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="sfTerminationNo"
        label="解约合同编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="premiseName"
        label="小区"
        width="180">
      </el-table-column>
      <el-table-column
        label="解约类型">
        <template slot-scope="scope">
          <span v-if="scope.row.terminationType==1">合同到期</span>
          <span v-if="scope.row.terminationType==2">业主提前解约</span>
          <span v-if="scope.row.terminationType==3">我方退租解约</span>
          <span v-if="scope.row.terminationType==4">其他</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="terminationDate"
        label="审核日期">
      </el-table-column>
      <el-table-column
        prop="auditDate"
        label="解约日期">
      </el-table-column>
      <el-table-column
        prop="finalStatement"
        label="结算金额">
      </el-table-column>
      <el-table-column
        prop="inputDate"
        label="录入日期">
      </el-table-column>
      <el-table-column
        prop="username"
        label="操作人">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="form.pageNum"
      :page-sizes="[10,20]"
      :page-size="form.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  created() {
    this.init()
  },
  data() {
    return {
      tableData: [],
      total:null,
      form:{
        pageNum:null,
        pageSize:null,
        sfTerminationNo:'',
        premiseName:'',
        username:'',
        t1:null,
        t2:null
      }
    }
  },
  methods: {
    init(){
      console.log(this.form.ownerName)
      this.axios.get("http://127.0.0.1/api/shou/wish/t-sf-termination/list",{params:this.form}).then((response)=>{
        this.tableData=response.data.obj.list
        this.form.pageNum=response.data.obj.pageNum
        this.form.pageSize=response.data.obj.pageSize
        this.total=response.data.obj.total
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.form.pageSize=val
      this.init()
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.form.pageNum=val
      this.init()
    },
    onSubmit() {
      this.init()
    },
    empty(){
      this.form.sfTerminationNo=''
      this.form.username=''
      this.form.premiseName=''
      this.form.t1=null
      this.form.t2=null
    }
  }
}
</script>

<style scoped>

</style>
